<?php
echo '<script type="text/javascript" src="'.SCRIPT_DIR.'/js/functionDisplayDirectory.js"></script>';
echo '<ul>';

require_once MODEL_DIR.'/SourceEditorModel.php';
$oEditorInstance = new SourceEditorModel(array('sCurrentDirectory' => '../'));

$asaDirectoryContent = SourceEditorModel::listCurrentDirectory();
echo '<ul>';
foreach($asaDirectoryContent['aisDirectoryInfos'] AS $sDirectoryName){
	if($sDirectoryName == '.'){
		$explorerRowContent = '<li id="'.$sDirectoryName.'">
			<img src="public/image/folder.gif" alt="folder" />
				'.$sDirectoryName.'
		</li>';
	}else{
		$explorerRowContent = '<li id="'.$sDirectoryName.'">
			<img src="public/image/folder.gif" alt="folder" />
			<a href="#'.$sDirectoryName.'" onClick="javascript:displayDirectory(\''.$sDirectoryName.'\');">
				'.$sDirectoryName.'
			</a>
		</li>';
	}
	echo $explorerRowContent;
}

foreach($asaDirectoryContent['aiassFilesInfos'] AS $iFile){
	switch($iFile['sExtensionFile']){
		case 'html':
		case 'xhtml':
		case 'phtml':
			$sImage = 'page_html.gif';
			break;

		case 'php':
			$sImage = 'page_php.gif';
			break;

		case 'java':
			$sImage = 'page_java.gif';
			break;

		case 'xml':
		case 'xsl':
		case 'dtd':
		case 'js':
			$sImage = 'page_script.gif';
			break;

		default:
			$sImage = 'page_text.gif';
			break;
	}
	echo '
		<li>
			<img src="'.IMAGE_DIR.'/'.$sImage.'" alt="file" />
			<a href="index.php?page=adminIndex&mod=displayFile&fileName='.$iFile['sCompleteNameFile'].'&amp;language='.$iFile['sExtensionFile'].'">
				'.$iFile['sCompleteNameFile'].'
			</a>
		</li>'
	;
}
echo '</ul>';
